import {defineStore} from 'pinia'
import {IState} from '../types'
const useUsersStore=defineStore('users',{
    state:():IState=>{
        return{
            name:'张三丰',
            age:120,
            job:'武当派掌门',
            gender:'男'
        }
    },
    getters:{
      getUserInfo(state):string{
        return `姓名:${state.name},年龄:${state.age},职位:${state.job},性别：${state.gender}`
      }
    },
    actions:{
        setUserInfo(name:string,age:number,job:string,gender:string){
            this.name=name
            this.age=age
            this.job=job
            this.gender=gender
        }
    },
    persist:{
        enabled:true,
        strategies:[
            {
                key:'giles_couter',
                storage:localStorage,
                paths:['name','job']
            }
        ]
    }

})
export default useUsersStore